package com.sk.bilibili.apiMapper.scanner;

import com.sk.bilibili.apiMapper.annotation.ApiMapperScan;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author 邵康
 * @date 2021/8/9 16:12
 */
public class ApiMapperScannerRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata metadata,
                                        BeanDefinitionRegistry registry) {
        AnnotationAttributes annoAttrs = AnnotationAttributes.fromMap(metadata
                .getAnnotationAttributes(ApiMapperScan.class.getName()));
        ApiMapperScanner scanner = new ApiMapperScanner(registry);
        scanner.doScan(annoAttrs.getStringArray("value"));
    }

}
